<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>购物车管理</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
		$(document).ready(function() {
			
		});
		function page(n,s){
			$("#pageNo").val(n);
			$("#pageSize").val(s);
			$("#searchForm").submit();
        	return false;
        }
		
		function toStudentJoin()
		{
			location = ctx + "/ems/emsJoin";
		}
		
		function toMyCartList(obj)
		{
			location = "${ctx}/ems/emsCart/myCartList?discountType="+obj.value;
		}
		
		function submitOrder()
		{
			var payType = $("#payType").val();
			if(!payType)
			{
				alert("请选择右上角的收费方式");
				return false;
			}
			if(confirm("请确认是否已收费，确定订单后，报名完成。"))
			{
				$("#searchForm").submit();
			}
		}
	</script>
</head>
<body>
	<form:form id="searchForm" action="${ctx}/ems/emsOrder/save" method="post" class="breadcrumb form-search">
	<ul class="nav nav-tabs">
		<li class="active"><a href="${ctx}/ems/emsCart/myCartList">我的购物车</a></li>
		<li style="line-height: 40px;"><font color="red" size="5px;">注意：现场收费完成后，切莫忘记点击“确认订单”完成报名；购物车内课程数量不能超过20条。</font></li>
		<li style="line-height: 40px; margin-left: 10px;">
		选择收费方式：
			<select style="width: 100px;" id="payType" name="payType">
				<option value="">---请选择---</option>
				<c:forEach items="${payTypes }" var="papType">
					<option value="${papType.value }">${papType.label }</option>
				</c:forEach>
			</select>
		</li>
		<li style="line-height: 40px; margin-left: 10px;">
		优惠方式：
			<select style="width: 100px;" name="discountType" onchange="toMyCartList(this);">
				<!-- <option value="">---请选择---</option> -->
				<c:forEach items="${discountTypes }" var="discType">
					<option ${discountType eq discType.value?'selected':''} value="${discType.value }">${discType.label }</option>
				</c:forEach>
			</select>
		</li>
		
		<%-- <shiro:hasPermission name="ems:emsCart:edit"><li><a href="${ctx}/ems/emsCart/form">购物车添加</a></li></shiro:hasPermission> --%>
		</ul>
	
		<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
		<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
		<input type="hidden" name="type" value="1"/>
		<input type="hidden" name="orderFrom" value="pc"/>
		
		<input type="hidden" name="personNum" value="${map.personNum }"/>
		<input type="hidden" name="personTime" value="${map.personTime }"/>
		<input type="hidden" name="sumMoney" value="${map.totalPriceFee }"/>
		<input type="hidden" name="payMoney" value="${map.totalRealFee }"/>
		
		
		<!-- <ul class="ul-form">
			<li class="btns"><input id="btnSubmit" class="btn btn-primary" type="submit" value="查询"/></li>
			<li class="clearfix"></li>
		</ul> -->
	
	<c:if test="${empty page || empty page.list}">
		<div style="text-align: center;">
			<font style="font-size: 30px;line-height: 100px;">
				购物车为空
			</font>
		</div>
		<div style="text-align: center;">
			<input id="studentJoin" class="btn btn-primary" onclick="toStudentJoin();" type="button" value="去报名"/>
		</div>
	</c:if>
	<c:if test="${not empty page && not empty page.list}">
	<sys:message content="${message}"/>
	<table id="contentTable" class="table table-striped table-bordered table-condensed">
		<thead>
			<tr>
				<th>学员</th>
				<th>电话</th>
				<th>报名课程</th>
				<th>报名学费</th>
				<th>优惠后学费</th>
				<th>现场折扣</th>
				<th>课程专业</th>
				<th>操作人</th>
				<th>创建时间</th>
				<!-- <th>备注</th> -->
				<th>操作</th>
				<shiro:hasPermission name="ems:emsCart:edit"><th>操作</th></shiro:hasPermission>
			</tr>
		</thead>
		<tbody>
		<c:forEach items="${page.list}" var="emsCart" varStatus="stat">
			<tr>
				<td>
					${emsCart.student.name}
					<input type="hidden" name="cartHisList[${stat.index }].id" value="${emsCart.id }"/>
					<input type="hidden" name="cartHisList[${stat.index }].payMoney" value="${emsCart.payMoney }"/>
				</td>
				<td>
					${emsCart.student.mobile}
				</td>
				<td>
					${emsCart.course.name}
				</td>
				<td>
					${emsCart.course.fee}
				</td>
				<td>
					${emsCart.payMoney}
				</td>
				<td>
					${emsCart.siteDiscount}
				</td>
				<td>
					${emsCart.course.major.name}
				</td>
				<td>
					${emsCart.createBy.name}
				</td>
				<td>
					<a href="${ctx}/ems/emsCart/form?id=${emsCart.id}">
						<fmt:formatDate value="${emsCart.createDate}" pattern="yyyy-MM-dd HH:mm:ss"/>
					</a>
				</td>
				<%-- <td>
					${emsCart.remarks}
				</td> --%>
			<shiro:hasPermission name="ems:emsStudent:edit"><td>
					<a href="${ctx}/ems/emsCart/delete?id=${emsCart.id}" onclick="return confirmx('确认要删除购物车中该条记录吗？', this.href)">删除</a>
				</td></shiro:hasPermission>
			</tr>
		</c:forEach>
		</tbody>
	</table>
	<div class="pagination">${page}</div>
	<div style="text-align: center;font-size: 16px;">
		报名人数：<font color="red"><b>${map.personNum }</b></font>人；报名人次：<font color="red"><b>${map.personTime }</b></font>人； 
		原学费总额：<font color="red"><b>${map.totalPriceFee }</b></font>元； 优惠后应付金额：<font color="red"><b>${map.totalRealFee }</b></font>元；
	</div>
	<br/>
	<div style="text-align: center;">
	<input id="studentJoin" class="btn btn-primary" onclick="toStudentJoin();" type="button" value="继续报名"/>&nbsp;&nbsp;&nbsp;
	<input id="btnSubmit" class="btn btn-primary" type="button" onclick="submitOrder();" value="确认订单"/>
	</div>
	</c:if>
	</form:form>
</body>
</html>